﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Windows.Data;

namespace MediaPlayer {
    /// <summary>
    /// 
    /// </summary>
    public class CameraInfo : INotifyPropertyChanged {
        /// <summary>
        /// Gets the request time.
        /// </summary>
        public DateTime RequestTime {
            get {
                return new DateTime(
                    SelectedDate.Year,
                    SelectedDate.Month,
                    SelectedDate.Day,
                    SelectedTime.Hour,
                    SelectedTime.Minute,
                    SelectedTime.Second
                    );
            }
        }
        /// <summary>
        /// 
        /// </summary>
        private DateTime m_selectedDate;
        /// <summary>
        /// Gets or sets the selected date time.
        /// </summary>
        /// <value>
        /// The selected date time.
        /// </value>
        public DateTime SelectedDate {
            get {
                return m_selectedDate;
            }
            set {
                if (m_selectedDate != value) {
                    m_selectedDate = value;
                    OnNotifyPropertyChanged("SelectedDate");
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        private DateTime m_selectedTime;
        /// <summary>
        /// Gets or sets the selected time.
        /// </summary>
        /// <value>
        /// The selected time.
        /// </value>
        public DateTime SelectedTime {
            get {
                return m_selectedTime;
            }
            set {
                if (m_selectedTime != value) {
                    m_selectedTime = value;
                    OnNotifyPropertyChanged("SelectedTime");
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        private long m_currentFrame;
        /// <summary>
        /// Initializes a new instance of the <see cref="CameraInfo"/> class.
        /// </summary>
        public CameraInfo() {
            SpeedRate = 1;
            m_selectedDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0,
                                              0, 0);
            SelectedTime = new DateTime(DateTime.Now.Year,
                DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, 0, 0);
        }
        /// <summary>
        /// Gets or sets the ID.
        /// </summary>
        /// <value>
        /// The ID.
        /// </value>
        public string ID { get; set; }
        /// <summary>
        /// Gets or sets the IP.
        /// </summary>
        /// <value>
        /// The IP.
        /// </value>
        public string IP {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the username.
        /// </summary>
        /// <value>
        /// The username.
        /// </value>
        public string Username {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the password.
        /// </summary>
        /// <value>
        /// The password.
        /// </value>
        public string Password {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the current frame.
        /// </summary>
        /// <value>
        /// The current frame.
        /// </value>
        public long CurrentFrame {
            get {
                return m_currentFrame;
            }
            set {
                if (m_currentFrame != value) {
                    m_currentFrame = value;
                    OnNotifyPropertyChanged("CurrentFrame");
                }
            }
        }
        /// <summary>
        /// Gets or sets a value indicating whether this instance is initial.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is initial; otherwise, <c>false</c>.
        /// </value>
        public bool IsInitial {
            get;
            set;
        }
        private bool m_isPlaying;
        /// <summary>
        /// Gets or sets a value indicating whether this instance is pause.
        /// </summary>
        /// <value>
        ///   <c>true</c> if this instance is pause; otherwise, <c>false</c>.
        /// </value>
        public bool IsPlaying {
            get {
                return m_isPlaying;
            }
            set {
                if (m_isPlaying != value) {
                    m_isPlaying = value;
                    OnNotifyPropertyChanged("IsPlaying");
                    IsEnable = !value;
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        private bool m_isEnable = true;
        /// <summary>
        /// Gets a value indicating whether this instance is enable.
        /// </summary>
        /// <value>
        ///   <c>true</c> if this instance is enable; otherwise, <c>false</c>.
        /// </value>
        public bool IsEnable {
            get {
                return m_isEnable;
            }
            private set {
                if (m_isEnable != value) {
                    m_isEnable = value;
                    OnNotifyPropertyChanged("IsEnable");
                }
            }
        }
        /// <summary>
        /// Gets or sets a value indicating whether [speed rate].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [speed rate]; otherwise, <c>false</c>.
        /// </value>
        public int SpeedRate {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets a value indicating whether this instance is next frame.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is next frame; otherwise, <c>false</c>.
        /// </value>
        public bool IsNextFrame {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets a value indicating whether this instance is back frame.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is back frame; otherwise, <c>false</c>.
        /// </value>
        public bool IsBackFrame {
            get;
            set;
        }
        /// <summary>
        /// Gets or sets the max frame.
        /// </summary>
        /// <value>
        /// The max frame.
        /// </value>
        public long MaxFrame {
            get {
                return m_maxFrame;
            }
            set {
                if (m_maxFrame != value) {
                    m_maxFrame = value;
                    OnNotifyPropertyChanged("MaxFrame");
                }
            }
        }
        /// <summary>
        /// 
        /// </summary>
        private long m_maxFrame;
        private string m_startTime;
        public string StartTime {
            get {
                return m_startTime;
            }
            set {
                if (m_startTime != value) {
                    m_startTime = value;
                    OnNotifyPropertyChanged("StartTime");
                }
            }
        }
        private string m_endTime;
        public string EndTime {
            get {
                return m_endTime;
            }
            set {
                if (m_endTime != value) {
                    m_endTime = value;
                    OnNotifyPropertyChanged("EndTime");
                }
            }
        }

        #region INotifyPropertyChanged Members

        private void OnNotifyPropertyChanged(string name) {
            if (PropertyChanged != null) {
                PropertyChanged(this, new PropertyChangedEventArgs(name));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
    /// <summary>
    /// 
    /// </summary>
    public class CameraInfos : INotifyPropertyChanged {
        public string WcfUrl {
            get;
            set;
        }

        /// <summary>
        /// Gets the cameras view.
        /// </summary>
        public ICollectionView CamerasView {
            get {
                return CollectionViewSource.GetDefaultView(Cameras);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="CameraInfos"/> class.
        /// </summary>
        public CameraInfos() {
            Cameras = new ObservableCollection<CameraInfo>();
        }
        /// <summary>
        /// Gets or sets the cameras.
        /// </summary>
        /// <value>
        /// The cameras.
        /// </value>
        public ObservableCollection<CameraInfo> Cameras { get; set; }

        #region INotifyPropertyChanged Members

        /// <summary>
        /// Occurs when a property value changes.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
